import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

public class T extends JFrame implements ActionListener{
    JButton jb;
    JTextField jf1,jf2;
    JLabel jl1,jl2;
    JPasswordField jwf;
    JComboBox<String> jcb;
    JRadioButton jrb1,jrb2;
    JCheckBox jceb;
    public T(String title) {
        super(title);
        //FlowLayout f1=new FlowLayout();
        setLayout(new FlowLayout());
        setBounds(100,100,800,150);
        jb=new JButton("判断");
        jl1=new JLabel("请输入用户名：");
        jf1=new JTextField(5);
        jl2=new JLabel("请输入密码：");
        jwf=new JPasswordField(10);
        //jf2=new JTextField(10);

        jcb=new JComboBox(new String[]{"男","女"});
        jrb1=new JRadioButton("man");
        jrb1.setSelected(true);
        jrb2=new JRadioButton("female");

        add(jl1);add(jf1);add(jl2);add(jwf);
        add(jcb);
        add(jb);
        jb.addActionListener(this);

        add(jrb1);add(jrb2);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);

    }
    public static void main(String[] args) {
        T a=new T("test");
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        if(jf1.getText().equals("张三")&&String.valueOf(jwf.getPassword()).equals("123")
                &&jcb.getSelectedItem().equals("男")) {
            Container c=this.getContentPane();
            c.setBackground(Color.green);
        }else {
            Container c=this.getContentPane();
            c.setBackground(Color.red);
        }
    }
//	public static void main(String[] args) {
//		JFrame window1=new JFrame("window1");
//		window1.setSize(500, 600);
//		Container c=window1.getContentPane();
//		//window1.setTitle("hhh");
//		window1.setVisible(true);
//		window1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		System.out.println(123+"abc");
//	}
}
